package com.zoran.study.spring.common;

/**
 * Common error code definition. Do not modify this file.
 *
 * @author Winter Gao
 *
 */
public enum CommonErrors implements ErrorCode {

    // 1000XX common errors
    COMMON_INTERNAL_ERROR(100001),

    COMMON_UNSUPPORTED_MEDIA_TYPE(100002),

    COMMON_METHOD_NOT_ALLOWED(100003),

    COMMON_UNAUTHORIZED(100004),

    COMMON_OPERATION_NOT_ALLOWED(100005),

    COMMON_ILLEGAL_ARGUMENT(100010),

    COMMON_PARAMETER_MISSING(100011),

    COMMON_PARAMETER_TYPE_MISMATCH(100012),

    // 1001XX tenant
    TENANT_NOT_FOUND(100101),

    TENANT_ALREADY_EXISTS(100102),

    TENANT_DEACTIVATED(100103),

    // 1002XX user
    USER_NOT_FOUND(100201),

    USER_ALREADY_EXISTS(100202),

    USER_DEACTIVATED(100203),

    USER_LOCKED(100204),

    // 1003XX customer
    CUSTOMER_EXISTS(100301),

    CUSTOMER_NOT_FOUND(100302),

    CUSTOMER_DEACTIVATED(100303),

    CUSTOMER_LOCKED(100304),

    // 1004XX oauth2 client
    OAUTH2_CLIENT_NOT_FOUND(100401),

    OAUTH2_CLIENT_ALREADY_EXISTS(100402),

    OAUTH2_CLIENT_DEACTIVATED(100403),

    OAUTH2_CLIENT_INVALID_SCOPE(100404),

    OAUTH2_CLIENT_INVALID_GRANT(100405);

    private final int code;

    private CommonErrors(int code) {
        this.code = code;
    }

    @Override
    public int code() {
        return code;
    }

    @Override
    public String messageKey() {
        return name().replace('_', '.').toLowerCase();
    }

}
